<?php

defined('SYSPATH') or die('No direct script access.');

abstract class Controller_Service extends Controller {

    protected $_url_base_media;
    protected $_url_film_image;
    protected $_node_xml;
    protected $_portal_node_xml;
    protected $_check_login;
    
    public function before() {
        $o_config = Kohana::$config->load('template');
        $a_template = $o_config->service;
        if (!empty($a_template)) {
            foreach ($a_template as $key => $value) {
                $key = "_" . $key;
                $this->$key = $value;
            }
        }
        parent::before();
    }

    /**
     * code : View::set_global($name, $value);
     * @param <type> $name
     * @param <type> $value
     */
    public function __set($name, $value) {
        if (property_exists($this, $name)) {
            $this->$name = $value;
        }
    }

    /**
     *
     * @param <type> $name
     * @return <type>
     */
    public function __get($name) {
        if (property_exists($this, $name)) {
            return $this->$name;
        }
        return null;
    }

    /**
     * ex: $this->setTitle("Nahi");
     * $this->getTitle("Nahi");
     * just to build function setParame, getParame
     * @param <type> $name
     * @param <type> $arguments
     * @return <type>
     */
    public function __call($name, $arguments) {
        $s_action = strtolower(substr($name, 0, 3));
        $s_fun = strtolower(substr($name, 3));
        //for action getParame
        $s_fun = "_" . $s_fun;
        if ($s_action === "get") {
            return $this->$s_fun;
        }
        //for action setParame
        else if ($s_action === "set") {
            $this->$s_fun = $arguments[0];
        }
    }

}

?>
